package com.fast.common.web;

public abstract class AbstractController {
	
	private static final int SUCCESS_CODE = 200;
	
	private static final int FAIL_CODE = 400;
	
	
	private static final String EMPTY_MSG = "";
	
	private static final String EMPTY_OBJECT = "{}";
	
	
	protected Response success() {
		return success(EMPTY_OBJECT);
	}
	
	protected Response success(Object payload) {
		Response response = new Response(SUCCESS_CODE);
		response.setMsg(EMPTY_MSG);
		response.setPayload(payload);
		return response;
	}
	
	protected Response fail(String msg) {
		Response response = new Response(FAIL_CODE);
		response.setMsg(msg);
		response.setPayload(EMPTY_OBJECT);
		return response;
	}
	

}
